﻿#ifndef FORMATCONVERT_H
#define FORMATCONVERT_H

#include <QObject>
#include <QVideoFrame>

struct AVFrame;

enum FDJVideoType {
    FDJ_AVCOLOR_FORMAT_I420 = 0,
    FDJ_AVCOLOR_FORMAT_NV21 = 1,
    FDJ_AVCOLOR_FORMAT_NV12 = 3,
    FDJ_AVCOLOR_FORMAT_RGB565 = 7,
    FDJ_AVCOLOR_FORMAT_RGB24 = 8,
    FDJ_AVCOLOR_FORMAT_ARGB = 9,
    FDJ_AVCOLOR_FORMAT_RGBA = 10
};

struct VDFrame
{
    int width;
    int height;
    FDJVideoType format;
    int dataSize;
    char *buffer;
};

class AVVideoConvert : public QObject
{
    Q_OBJECT
public:

    /* 腾讯Frame（MAC平台） */
    static AVFrame *convertToFrame(const VDFrame *frame);

    /* 转同宽高 */
    static AVFrame *convertToFrame(const QVideoFrame &frame, QVideoFrame::PixelFormat _dstFormat);

    static AVFrame *convertToFrame(const QImage &image);

private:
    explicit AVVideoConvert();

};

#endif // FORMATCONVERT_H
